// 数据类型定义
export interface Project {
  id: number;
  name: string;
  name_en: string;
  description?: string;
  time_horizon: number;
  start_year: number;
  year_step: number;
  end_year: number;
  sort_order: number;
  created_at: string;
  updated_at: string;
  category_count?: number;
  parameter_count?: number;
}

export interface ProjectCreate {
  name: string;
  name_en: string;
  description?: string;
  time_horizon: number;
  start_year: number;
  year_step: number;
  end_year: number;
  sort_order?: number;
}

export interface ProjectUpdate {
  name?: string;
  name_en?: string;
  description?: string;
  sort_order?: number;
  time_horizon?: number;
  start_year?: number;
  year_step?: number;
  end_year?: number;
}

export interface ParameterCategory {
  id: number;
  project_id: number;
  name: string;
  name_en: string;
  description?: string;
  sort_order: number;
  created_at: string;
  updated_at: string;
  parameters?: Parameter[];
}

export interface ParameterCategoryCreate {
  name: string;
  name_en: string;
  description?: string;
  sort_order?: number;
}

export interface ParameterCategoryUpdate {
  name?: string;
  name_en?: string;
  description?: string;
  sort_order?: number;
}

export interface Parameter {
  id: number;
  category_id: number;
  name: string;
  name_en: string;
  param_type: 'integer' | 'float' | 'boolean' | 'string';
  unit?: string;
  description?: string;
  is_list: boolean;
  is_year_related: boolean;
  list_length?: number;
  sort_order: number;
  created_at: string;
  updated_at: string;
  values?: ParameterValue[];
}

export interface ParameterCreate {
  name: string;
  name_en: string;
  param_type: 'integer' | 'float' | 'boolean' | 'string';
  unit?: string;
  description?: string;
  is_list: boolean;
  is_year_related: boolean;
  list_length?: number;
  sort_order?: number;
}

export interface ParameterUpdate {
  name?: string;
  name_en?: string;
  unit?: string;
  description?: string;
  sort_order?: number;
}

export interface ParameterValue {
  id: number;
  parameter_id: number;
  value: string;
  list_index?: number;
  created_at: string;
  updated_at: string;
}

export interface ParameterValueCreate {
  value: string;
  list_index?: number;
}

export interface ParameterValueUpdate {
  value: string;
}

// API响应类型
export interface ApiResponse<T> {
  data: T;
  message?: string;
  success?: boolean;
}

export interface MessageResponse {
  message: string;
  success: boolean;
}

// 导出格式
export interface ExportFormat {
  format: string;
  name: string;
  extension: string;
  description?: string;
}

// 导入格式
export interface ImportFormat {
  format: string;
  name: string;
  extensions: string[];
  description?: string;
}

// 组件状态类型
export interface ProjectListState {
  projects: Project[];
  loading: boolean;
  error?: string;
}

export interface ProjectDetailState {
  project?: Project;
  categories: ParameterCategory[];
  loading: boolean;
  error?: string;
}

export interface CategoryDetailState {
  category?: ParameterCategory;
  parameters: Parameter[];
  loading: boolean;
  error?: string;
}

// 实验相关类型
export interface ExperimentRun {
  id: number;
  project_id: number;
  name?: string;
  description?: string;
  snapshot_file_path?: string;
  created_at: string;
}

export interface ExperimentDataCategory {
  id: number;
  name: string;
  description?: string;
  sort_order: number;
  created_at: string;
  series_data: ExperimentDataSeries[];
  scalar_data: ExperimentDataScalar[];
}

export interface ExperimentDataSeries {
  id: number;
  name: string;
  data_group?: string;
  parquet_path: string;
  unit?: string;
  description?: string;
  index_column_name: string;
  data_length: number;
  created_at: string;
}

export interface ExperimentDataScalar {
  id: number;
  name: string;
  data_group?: string;
  value: string; // JSON字符串
  unit?: string;
  description?: string;
  created_at: string;
}

export interface ExperimentResult {
  id: number;
  name: string;
  file_type: string;
  file_path: string;
  file_size?: number;
  description?: string;
  created_at: string;
}

export interface ExperimentFullData {
  id: number;
  project_id: number;
  name?: string;
  description?: string;
  snapshot_file_path?: string;
  created_at: string;
  results: ExperimentResult[];
  categories: ExperimentDataCategory[];
}

export interface ExperimentUpdate {
  name?: string;
  description?: string;
}
